{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pandas 百问百答 之 自定义排序\n",
    "## Python 大咖谈 ~ 呆鸟出品\n",
    "\n",
    "1. 自定义索引排序\n",
    "2. 自定义列值排序\n",
    "3. 利用辅助列实现自定义列值排序\n",
    "4. 自定义列序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.356782Z",
     "start_time": "2020-01-06T10:16:51.277997Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.446764Z",
     "start_time": "2020-01-06T10:16:52.360781Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司</th>\n",
       "      <th>销售额</th>\n",
       "      <th>门店</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>序号</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>上海</td>\n",
       "      <td>26677</td>\n",
       "      <td>上海一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>广州</td>\n",
       "      <td>16544</td>\n",
       "      <td>广州二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>深圳</td>\n",
       "      <td>15655</td>\n",
       "      <td>深圳二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>北京</td>\n",
       "      <td>36986</td>\n",
       "      <td>北京一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>上海</td>\n",
       "      <td>18923</td>\n",
       "      <td>上海二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>深圳</td>\n",
       "      <td>44161</td>\n",
       "      <td>深圳一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>广州</td>\n",
       "      <td>26409</td>\n",
       "      <td>广州一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>北京</td>\n",
       "      <td>93223</td>\n",
       "      <td>北京二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>北京</td>\n",
       "      <td>56586</td>\n",
       "      <td>北京三店</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   分公司    销售额    门店\n",
       "序号                 \n",
       "1   上海  26677  上海一店\n",
       "2   广州  16544  广州二店\n",
       "3   深圳  15655  深圳二店\n",
       "4   北京  36986  北京一店\n",
       "5   上海  18923  上海二店\n",
       "6   深圳  44161  深圳一店\n",
       "7   广州  26409  广州一店\n",
       "8   北京  93223  北京二店\n",
       "9   北京  56586  北京三店"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sales = pd.read_excel(\"data/自定义排序.xlsx\",\"销售数据\",index_col=\"序号\")\n",
    "sales"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "不论按升序，还是按降序排列，sort_values() 都不能实现我们想要的，按北京、上海、广州这样的自定义排序。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.473758Z",
     "start_time": "2020-01-06T10:16:52.450763Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司</th>\n",
       "      <th>销售额</th>\n",
       "      <th>门店</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>序号</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>上海</td>\n",
       "      <td>26677</td>\n",
       "      <td>上海一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>上海</td>\n",
       "      <td>18923</td>\n",
       "      <td>上海二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>北京</td>\n",
       "      <td>36986</td>\n",
       "      <td>北京一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>北京</td>\n",
       "      <td>56586</td>\n",
       "      <td>北京三店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>北京</td>\n",
       "      <td>93223</td>\n",
       "      <td>北京二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>广州</td>\n",
       "      <td>26409</td>\n",
       "      <td>广州一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>广州</td>\n",
       "      <td>16544</td>\n",
       "      <td>广州二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>深圳</td>\n",
       "      <td>44161</td>\n",
       "      <td>深圳一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>深圳</td>\n",
       "      <td>15655</td>\n",
       "      <td>深圳二店</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   分公司    销售额    门店\n",
       "序号                 \n",
       "1   上海  26677  上海一店\n",
       "5   上海  18923  上海二店\n",
       "4   北京  36986  北京一店\n",
       "9   北京  56586  北京三店\n",
       "8   北京  93223  北京二店\n",
       "7   广州  26409  广州一店\n",
       "2   广州  16544  广州二店\n",
       "6   深圳  44161  深圳一店\n",
       "3   深圳  15655  深圳二店"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sales.sort_values(by=[\"分公司\",\"门店\"],ascending=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 自定义索引排序\n",
    "\n",
    "要是数据量不大，可以尝试一下自定义索引排序。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.504752Z",
     "start_time": "2020-01-06T10:16:52.477757Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司</th>\n",
       "      <th>销售额</th>\n",
       "      <th>门店</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>序号</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>北京</td>\n",
       "      <td>36986</td>\n",
       "      <td>北京一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>北京</td>\n",
       "      <td>93223</td>\n",
       "      <td>北京二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>北京</td>\n",
       "      <td>56586</td>\n",
       "      <td>北京三店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>上海</td>\n",
       "      <td>26677</td>\n",
       "      <td>上海一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>上海</td>\n",
       "      <td>18923</td>\n",
       "      <td>上海二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>广州</td>\n",
       "      <td>26409</td>\n",
       "      <td>广州一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>广州</td>\n",
       "      <td>16544</td>\n",
       "      <td>广州二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>深圳</td>\n",
       "      <td>44161</td>\n",
       "      <td>深圳一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>深圳</td>\n",
       "      <td>15655</td>\n",
       "      <td>深圳二店</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   分公司    销售额    门店\n",
       "序号                 \n",
       "4   北京  36986  北京一店\n",
       "8   北京  93223  北京二店\n",
       "9   北京  56586  北京三店\n",
       "1   上海  26677  上海一店\n",
       "5   上海  18923  上海二店\n",
       "7   广州  26409  广州一店\n",
       "2   广州  16544  广州二店\n",
       "6   深圳  44161  深圳一店\n",
       "3   深圳  15655  深圳二店"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "reorder = [4,8,9,1,5,7,2,6,3]\n",
    "\n",
    "sales.reindex(reorder)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "虽然只有 9 条数据，但这种一个一个写索引，呆鸟已经看的头晕眼花了，这要再多点，更受不了了，显然，数据量稍微多一些，这种方式就不适合了。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 自定义列值排序\n",
    "\n",
    "下面，我们学习一种更简单，更直观的方式。\n",
    "\n",
    "这里的原理是把列转换为类别型，通过指定**类别排序**，按列值排序。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.548743Z",
     "start_time": "2020-01-06T10:16:52.514750Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司</th>\n",
       "      <th>销售额</th>\n",
       "      <th>门店</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>序号</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>北京</td>\n",
       "      <td>36986</td>\n",
       "      <td>北京一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>北京</td>\n",
       "      <td>93223</td>\n",
       "      <td>北京二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>北京</td>\n",
       "      <td>56586</td>\n",
       "      <td>北京三店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>上海</td>\n",
       "      <td>26677</td>\n",
       "      <td>上海一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>上海</td>\n",
       "      <td>18923</td>\n",
       "      <td>上海二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>广州</td>\n",
       "      <td>16544</td>\n",
       "      <td>广州二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>广州</td>\n",
       "      <td>26409</td>\n",
       "      <td>广州一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>深圳</td>\n",
       "      <td>15655</td>\n",
       "      <td>深圳二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>深圳</td>\n",
       "      <td>44161</td>\n",
       "      <td>深圳一店</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   分公司    销售额    门店\n",
       "序号                 \n",
       "4   北京  36986  北京一店\n",
       "8   北京  93223  北京二店\n",
       "9   北京  56586  北京三店\n",
       "1   上海  26677  上海一店\n",
       "5   上海  18923  上海二店\n",
       "2   广州  16544  广州二店\n",
       "7   广州  26409  广州一店\n",
       "3   深圳  15655  深圳二店\n",
       "6   深圳  44161  深圳一店"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sales['分公司'] = pd.Categorical(sales['分公司'], categories=[\n",
    "                              '北京', '上海', '广州', '深圳'], ordered=True)\n",
    "\n",
    "sales.sort_values(by='分公司')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这样很方便地就实现了按分公司排列，但并未实现门店列的排序，比如，广州与深圳的二店排在了一店前面。\n",
    "\n",
    "虽然，也可以把门店列改为类别型，但门店很多就不直观了，因此，我们再引入一种方式。\n",
    "\n",
    "同时，也请注意，类似这种分公司与门店名称的排序，要在设计数据库时提供分公司与门店代码，在数据导出时也要导出相应代码，代码依据规律创建，在排序时就可以用上。\n",
    "\n",
    "如果代码规律与排序规律还是不一致，就只好自行维护一套自定义规律表了。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 利用辅助列实现自定义列值排序"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T08:52:17.987726Z",
     "start_time": "2020-01-06T08:52:17.976725Z"
    }
   },
   "source": [
    "首先，要导入自定义的分公司与门店代码表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.593734Z",
     "start_time": "2020-01-06T10:16:52.552742Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司代码</th>\n",
       "      <th>分公司</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>上海</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>广州</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>深圳</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       分公司代码 分公司\n",
       "0  Branch001  北京\n",
       "1  Branch002  上海\n",
       "2  Branch003  广州\n",
       "3  Branch004  深圳"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "branch = pd.read_excel('data/自定义排序.xlsx','分公司代码')\n",
    "branch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.637725Z",
     "start_time": "2020-01-06T10:16:52.601733Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>门店代码</th>\n",
       "      <th>门店</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>bj_001</td>\n",
       "      <td>北京一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>bj_002</td>\n",
       "      <td>北京二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>bj_003</td>\n",
       "      <td>北京三店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>sh_001</td>\n",
       "      <td>上海一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>sh_002</td>\n",
       "      <td>上海二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>gz_001</td>\n",
       "      <td>广州一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>gz_002</td>\n",
       "      <td>广州二店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>sz_001</td>\n",
       "      <td>深圳一店</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>sz_002</td>\n",
       "      <td>深圳二店</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     门店代码    门店\n",
       "0  bj_001  北京一店\n",
       "1  bj_002  北京二店\n",
       "2  bj_003  北京三店\n",
       "3  sh_001  上海一店\n",
       "4  sh_002  上海二店\n",
       "5  gz_001  广州一店\n",
       "6  gz_002  广州二店\n",
       "7  sz_001  深圳一店\n",
       "8  sz_002  深圳二店"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "department = pd.read_excel('data/自定义排序.xlsx','门店代码')\n",
    "department"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.690715Z",
     "start_time": "2020-01-06T10:16:52.645724Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司</th>\n",
       "      <th>销售额</th>\n",
       "      <th>门店</th>\n",
       "      <th>分公司代码</th>\n",
       "      <th>门店代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>上海</td>\n",
       "      <td>26677</td>\n",
       "      <td>上海一店</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>sh_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>广州</td>\n",
       "      <td>16544</td>\n",
       "      <td>广州二店</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>gz_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>深圳</td>\n",
       "      <td>15655</td>\n",
       "      <td>深圳二店</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>sz_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>北京</td>\n",
       "      <td>36986</td>\n",
       "      <td>北京一店</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>bj_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>上海</td>\n",
       "      <td>18923</td>\n",
       "      <td>上海二店</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>sh_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>深圳</td>\n",
       "      <td>44161</td>\n",
       "      <td>深圳一店</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>sz_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>广州</td>\n",
       "      <td>26409</td>\n",
       "      <td>广州一店</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>gz_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>北京</td>\n",
       "      <td>93223</td>\n",
       "      <td>北京二店</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>bj_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>北京</td>\n",
       "      <td>56586</td>\n",
       "      <td>北京三店</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>bj_003</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  分公司    销售额    门店      分公司代码    门店代码\n",
       "0  上海  26677  上海一店  Branch002  sh_001\n",
       "1  广州  16544  广州二店  Branch003  gz_002\n",
       "2  深圳  15655  深圳二店  Branch004  sz_002\n",
       "3  北京  36986  北京一店  Branch001  bj_001\n",
       "4  上海  18923  上海二店  Branch002  sh_002\n",
       "5  深圳  44161  深圳一店  Branch004  sz_001\n",
       "6  广州  26409  广州一店  Branch003  gz_001\n",
       "7  北京  93223  北京二店  Branch001  bj_002\n",
       "8  北京  56586  北京三店  Branch001  bj_003"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sales = pd.merge(sales, branch, on=\"分公司\", how=\"left\")\n",
    "sales = pd.merge(sales, department, on=\"门店\",how=\"left\")\n",
    "sales"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在，用 `sort_values()`，就可以实现自定义排序了。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.716710Z",
     "start_time": "2020-01-06T10:16:52.694714Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司</th>\n",
       "      <th>销售额</th>\n",
       "      <th>门店</th>\n",
       "      <th>分公司代码</th>\n",
       "      <th>门店代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>北京</td>\n",
       "      <td>36986</td>\n",
       "      <td>北京一店</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>bj_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>北京</td>\n",
       "      <td>93223</td>\n",
       "      <td>北京二店</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>bj_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>北京</td>\n",
       "      <td>56586</td>\n",
       "      <td>北京三店</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>bj_003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>上海</td>\n",
       "      <td>26677</td>\n",
       "      <td>上海一店</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>sh_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>上海</td>\n",
       "      <td>18923</td>\n",
       "      <td>上海二店</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>sh_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>广州</td>\n",
       "      <td>26409</td>\n",
       "      <td>广州一店</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>gz_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>广州</td>\n",
       "      <td>16544</td>\n",
       "      <td>广州二店</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>gz_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>深圳</td>\n",
       "      <td>44161</td>\n",
       "      <td>深圳一店</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>sz_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>深圳</td>\n",
       "      <td>15655</td>\n",
       "      <td>深圳二店</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>sz_002</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  分公司    销售额    门店      分公司代码    门店代码\n",
       "3  北京  36986  北京一店  Branch001  bj_001\n",
       "7  北京  93223  北京二店  Branch001  bj_002\n",
       "8  北京  56586  北京三店  Branch001  bj_003\n",
       "0  上海  26677  上海一店  Branch002  sh_001\n",
       "4  上海  18923  上海二店  Branch002  sh_002\n",
       "6  广州  26409  广州一店  Branch003  gz_001\n",
       "1  广州  16544  广州二店  Branch003  gz_002\n",
       "5  深圳  44161  深圳一店  Branch004  sz_001\n",
       "2  深圳  15655  深圳二店  Branch004  sz_002"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sales.sort_values(['分公司代码','门店代码'],inplace=True)\n",
    "sales"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 自定义列序"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "到目前为止，列序有些乱，严总看了，肯定又会批评不注意细节了，所以还要按以下顺序重排列序：分公司代码、分公司、门店代码、门店、销售额。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.736706Z",
     "start_time": "2020-01-06T10:16:52.721709Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司</th>\n",
       "      <th>分公司代码</th>\n",
       "      <th>销售额</th>\n",
       "      <th>门店</th>\n",
       "      <th>门店代码</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>北京</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>36986</td>\n",
       "      <td>北京一店</td>\n",
       "      <td>bj_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>北京</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>93223</td>\n",
       "      <td>北京二店</td>\n",
       "      <td>bj_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>北京</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>56586</td>\n",
       "      <td>北京三店</td>\n",
       "      <td>bj_003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>上海</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>26677</td>\n",
       "      <td>上海一店</td>\n",
       "      <td>sh_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>上海</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>18923</td>\n",
       "      <td>上海二店</td>\n",
       "      <td>sh_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>广州</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>26409</td>\n",
       "      <td>广州一店</td>\n",
       "      <td>gz_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>广州</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>16544</td>\n",
       "      <td>广州二店</td>\n",
       "      <td>gz_002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>深圳</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>44161</td>\n",
       "      <td>深圳一店</td>\n",
       "      <td>sz_001</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>深圳</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>15655</td>\n",
       "      <td>深圳二店</td>\n",
       "      <td>sz_002</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  分公司      分公司代码    销售额    门店    门店代码\n",
       "3  北京  Branch001  36986  北京一店  bj_001\n",
       "7  北京  Branch001  93223  北京二店  bj_002\n",
       "8  北京  Branch001  56586  北京三店  bj_003\n",
       "0  上海  Branch002  26677  上海一店  sh_001\n",
       "4  上海  Branch002  18923  上海二店  sh_002\n",
       "6  广州  Branch003  26409  广州一店  gz_001\n",
       "1  广州  Branch003  16544  广州二店  gz_002\n",
       "5  深圳  Branch004  44161  深圳一店  sz_001\n",
       "2  深圳  Branch004  15655  深圳二店  sz_002"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sales.sort_index(axis='columns',ascending=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从上面的列子可以看到，`sort_index()` 只支持按字母或数字排序，不支持自定义列排序，咱们还得想办法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.762700Z",
     "start_time": "2020-01-06T10:16:52.740705Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司代码</th>\n",
       "      <th>分公司</th>\n",
       "      <th>门店代码</th>\n",
       "      <th>门店</th>\n",
       "      <th>销售额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>北京</td>\n",
       "      <td>bj_001</td>\n",
       "      <td>北京一店</td>\n",
       "      <td>36986</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>北京</td>\n",
       "      <td>bj_002</td>\n",
       "      <td>北京二店</td>\n",
       "      <td>93223</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>Branch001</td>\n",
       "      <td>北京</td>\n",
       "      <td>bj_003</td>\n",
       "      <td>北京三店</td>\n",
       "      <td>56586</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>上海</td>\n",
       "      <td>sh_001</td>\n",
       "      <td>上海一店</td>\n",
       "      <td>26677</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>Branch002</td>\n",
       "      <td>上海</td>\n",
       "      <td>sh_002</td>\n",
       "      <td>上海二店</td>\n",
       "      <td>18923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>广州</td>\n",
       "      <td>gz_001</td>\n",
       "      <td>广州一店</td>\n",
       "      <td>26409</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>Branch003</td>\n",
       "      <td>广州</td>\n",
       "      <td>gz_002</td>\n",
       "      <td>广州二店</td>\n",
       "      <td>16544</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>深圳</td>\n",
       "      <td>sz_001</td>\n",
       "      <td>深圳一店</td>\n",
       "      <td>44161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>Branch004</td>\n",
       "      <td>深圳</td>\n",
       "      <td>sz_002</td>\n",
       "      <td>深圳二店</td>\n",
       "      <td>15655</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       分公司代码 分公司    门店代码    门店    销售额\n",
       "3  Branch001  北京  bj_001  北京一店  36986\n",
       "7  Branch001  北京  bj_002  北京二店  93223\n",
       "8  Branch001  北京  bj_003  北京三店  56586\n",
       "0  Branch002  上海  sh_001  上海一店  26677\n",
       "4  Branch002  上海  sh_002  上海二店  18923\n",
       "6  Branch003  广州  gz_001  广州一店  26409\n",
       "1  Branch003  广州  gz_002  广州二店  16544\n",
       "5  Branch004  深圳  sz_001  深圳一店  44161\n",
       "2  Branch004  深圳  sz_002  深圳二店  15655"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sales = sales[['分公司代码', '分公司', '门店代码', '门店', '销售额']]\n",
    "sales"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "至此，列序也排好了，但这就完了吗？\n",
    "\n",
    "如果这样给严总，**肯定还会挨批！**\n",
    "\n",
    "为什么呢？\n",
    "\n",
    "大家看下 index， 也就是索引序号，是不是乱序的？另外对严总来说，他并不关心这些代码，对他来说只是冗余信息，影响他看数据的效率与效果，所以也应该去掉。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.777697Z",
     "start_time": "2020-01-06T10:16:52.766700Z"
    }
   },
   "outputs": [],
   "source": [
    "# 删掉没用的列\n",
    "del sales['分公司代码'], sales['门店代码']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-01-06T10:16:52.799693Z",
     "start_time": "2020-01-06T10:16:52.782696Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>分公司</th>\n",
       "      <th>门店</th>\n",
       "      <th>销售额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>北京</td>\n",
       "      <td>北京一店</td>\n",
       "      <td>36986</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>北京</td>\n",
       "      <td>北京二店</td>\n",
       "      <td>93223</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>北京</td>\n",
       "      <td>北京三店</td>\n",
       "      <td>56586</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>上海</td>\n",
       "      <td>上海一店</td>\n",
       "      <td>26677</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>上海</td>\n",
       "      <td>上海二店</td>\n",
       "      <td>18923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>广州</td>\n",
       "      <td>广州一店</td>\n",
       "      <td>26409</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>广州</td>\n",
       "      <td>广州二店</td>\n",
       "      <td>16544</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>深圳</td>\n",
       "      <td>深圳一店</td>\n",
       "      <td>44161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>深圳</td>\n",
       "      <td>深圳二店</td>\n",
       "      <td>15655</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  分公司    门店    销售额\n",
       "0  北京  北京一店  36986\n",
       "1  北京  北京二店  93223\n",
       "2  北京  北京三店  56586\n",
       "3  上海  上海一店  26677\n",
       "4  上海  上海二店  18923\n",
       "5  广州  广州一店  26409\n",
       "6  广州  广州二店  16544\n",
       "7  深圳  深圳一店  44161\n",
       "8  深圳  深圳二店  15655"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 重置索引\n",
    "sales.reset_index(drop=True,inplace=True)\n",
    "sales"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
